package com.cold.demo.web.service;

import org.springframework.stereotype.Service;

@Service
public class UserService1 extends UserService3 {


    static int a = 0, b = 0;
    static int x = 0, y = 0;

    public static void main(String[] args) throws InterruptedException {
        int i = 0;
        while (true) {
            a = 0;
            b = 0;
            x = 0;
            y = 0;

            Thread o = new Thread(() -> {
                a = y;
                x = 1;
            });

            Thread t = new Thread(() -> {
                b = x;
                y = 1;
            });

            o.start();
            t.start();
            o.join();
            t.join();
            i++;
            System.out.println("i=" + i + "\t\ta=" + a + " b=" + b);
            if (a == 1 && b == 1) {
                throw new IllegalArgumentException();
            }
        }
    }

}
